﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Adalbertus.BudgetPlanner.Domain;
using System.Diagnostics.Contracts;

namespace Adalbertus.BudgetPlanner.ViewModels.BudgetPlanning
{
    public class CashFlowVM
    {
        private CashFlow _wrappedCashFlow;
        public CashFlow WrappedCashFlow
        {
            get
            {
                Contract.Ensures(Contract.Result<CashFlow>() != null);
                return _wrappedCashFlow;
            }
        }

        public CashFlowVM(CashFlow cashFlow)
        {
            Contract.Requires<ArgumentNullException>(cashFlow != null, "cashFlow");
            _wrappedCashFlow = cashFlow;
        }

        public string Name
        {
            get
            {
                return ToString();
            }
        }

        public override string ToString()
        {
            if (string.IsNullOrWhiteSpace(WrappedCashFlow.Description))
            {
                return WrappedCashFlow.Name;
            }
            return string.Format("{0} ({1})", WrappedCashFlow.Name, WrappedCashFlow.Description);
        }
    }
}
